home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / hsclib / tag_a.c < prev    next >
C/C++ Source or Header  |  1996-10-13  |  2KB  |  101 lines

  1. /*
  2.  *  hsclib/tag_a.c
  3.  *
  4.  *  tag-callback for "<A..>" (anchor)
  5.  *
  6.  *  Copyright (C) 1995,96  Thomas Aglassinger
  7.  *
  8.  *  This program is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2 of the License, or
  11.  *  (at your option) any later version.
  12.  *
  13.  *  This program is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with this program; if not, write to the Free Software
  20.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  *  updated: 13-Oct-1996
  23.  *  created:  3-Aug-1995
  24.  */
  25.  
  26. #include "hsclib/inc_tagcb.h"
  27. #include "hscprj/document.h"
  28.  
  29. /*
  30.  *  TODO: strip only HREF part, if a NAME is within <A>
  31.  *  TODO: insabg, insaed: configurable format str for inserted anchors
  32.  *  TODO: local $INSANCH option for A HREF tag
  33.  */
  34.  
  35. /*
  36.  *  handle_anchor
  37.  *
  38.  *  handle tag <A>:
  39.  *  - check for HREF set
  40.  *  - update value for attribute HSC.ANCHOR
  41.  */
  42. BOOL handle_anchor(HSCPRC * hp, HSCTAG * tag)
  43. {
  44.     HSCVAR *vhref = find_varname(tag->attr, "HREF");
  45.     HSCVAR *vname = find_varname(tag->attr, "NAME");
  46.     HSCVAR *vid   = find_varname(tag->attr, "ID");
  47.     STRPTR href = NULL;
  48.     STRPTR name = NULL;
  49.     STRPTR id = NULL;
  50.  
  51.     /* set attribute values */
  52.     if (vhref)
  53.         href = vhref->text;
  54.     if (vname)
  55.         name = vname->text;
  56.     if (vid)
  57.         id = vid->text;
  58.  
  59.     /* tell parser that he is inside an anchor */
  60.     if (href)
  61.     {
  62.         HSCATTR *anchor_attr = find_varname(hp->defattr, ANCHOR_ATTR);
  63.  
  64.         if (anchor_attr)
  65.         {
  66.             set_vartext(anchor_attr, href);
  67.         }
  68.         else
  69.         {
  70.             panic("no anchor-attribute");
  71.         }
  72.  
  73.         hp->inside_anchor = TRUE;
  74.     }
  75.  
  76.     /* check for both HREF and NAME missing */
  77.     if ((!href) && (!name) && (!id))
  78.     {
  79.         hsc_message(hp, MSG_ANCH_NO_NMHR,
  80.                     "%T without HREF, NAME or ID", tag);
  81.     }
  82.  
  83.     return (TRUE);
  84. }
  85.  
  86. /*
  87.  *  handle_cancher
  88.  *
  89.  *  closing handle for <A>
  90.  */
  91. BOOL handle_canchor(HSCPRC * hp, HSCTAG * tag)
  92. {
  93.     hp->inside_anchor = FALSE;
  94.  
  95.     /* write whole tag */
  96.  
  97.     return (TRUE);
  98.  
  99. }
  100.  
  101.